package com.singfan.manage.vm.partial;

import com.singfan.core.dao.database.model.constant.BusinessStatusType;
import com.singfan.core.dao.database.model.constant.OrderStatusType;

/**
 * Author: hansonghe
 * Date: 2015-10-14 15:43
 * Desc:
 */
public class OrderItem{
    private long orderId;
    private String customerPhone;
    private String orderName;
    private int dayTime;
    private int clockTime;
    private String masterShopName;
    private String slaveShopName;
    private String barberName;
    private int price;
    private int status;

    public OrderItem(){}

    public long getOrderId() {
        return orderId;
    }

    public void setOrderId(long orderId) {
        this.orderId = orderId;
    }

    public String getCustomerPhone() {
        return customerPhone;
    }

    public void setCustomerPhone(String customerPhone) {
        this.customerPhone = customerPhone;
    }

    public String getOrderName() {
        return orderName;
    }

    public void setOrderName(String orderName) {
        this.orderName = orderName;
    }

    public int getDayTime() {
        return dayTime;
    }

    public void setDayTime(int dayTime) {
        this.dayTime = dayTime;
    }

    public int getClockTime() {
        return clockTime;
    }

    public void setClockTime(int clockTime) {
        this.clockTime = clockTime;
    }

    public String getMasterShopName() {
        return masterShopName;
    }

    public void setMasterShopName(String masterShopName) {
        this.masterShopName = masterShopName;
    }

    public String getSlaveShopName() {
        return slaveShopName;
    }

    public void setSlaveShopName(String slaveShopName) {
        this.slaveShopName = slaveShopName;
    }

    public String getBarberName() {
        return barberName;
    }

    public void setBarberName(String barberName) {
        this.barberName = barberName;
    }

    public int getPrice() {
        return price;
    }

    public void setPrice(int price) {
        this.price = price;
    }

    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }

    @Override
    public String toString() {
        String dayStr = String.valueOf(dayTime);
        String day = dayStr.substring(0,4) + "-" + dayStr.substring(4,6) + "-" + dayStr.substring(6,8);

        String clockStr = String.valueOf(clockTime);
        String clock = clockStr.substring(0, clockStr.length() - 2) + ":" + clockStr.substring(clockStr.length() - 2, clockStr.length());
        String refundTmp = "";
        if (status != OrderStatusType.REFUNDED){
            refundTmp = "<input type='button' value='设置已退款' onclick=\"orderRefund('" + orderId + "')\" />";
        }

        return String.format("<tr><td>%1$d</td><td>%2$s</td><td title='%3$s'>%3$s</td><td>%4$s</td><td>%5$s</td><td>%6$s</td><td>%7$s</td><td>%8$s</td><td>%9$s</td><td><input type='button' value='查看' onclick=\"viewOrderDetail('%1$d')\" />%10$s</td></tr>",orderId, customerPhone, orderName, day + " " + clock, masterShopName,slaveShopName, barberName, String.format("%.2f", price / 100.0) + " 元", OrderStatusType.getOrderStatusText(status), refundTmp);
    }
}